<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>父组件给子组件传值</title>
    <script src="lib/vue.js"></script>
</head>
<body>
    <div id="app">
        <my-parent></my-parent>
    </div>
</body>
<template id="parent">
    <div>
        <h1>Parent</h1>
        <my-child str="哈哈" :num="100" :flag="true" :msg="msg" :obj="{val: 1000}" :arr="['a', 'b', 'c', 'd']" ></my-child>
    </div>
</template>
<template id="child">
    <div>
        <h1>Child</h1>
        <ul>
            <li>{{ str }}</li>
            <li>{{ num }}</li>
            <li>{{ flag }}</li>
            <li>{{ msg }}</li>
            <li>{{ obj }}</li>
            <li>{{ arr }}</li>
        </ul>
    </div>
</template>

<script>
    const Child = {
        props: ["str", "num", "flag", "msg", "obj", "arr"],
        template: `#child`,
    }
    const Parent = {
        template: `#parent`,
        data(){
            return {
                msg: "hello vue",
            }
        },
        components:{
            "my-child": Child
        }
    }
    new Vue({
        el: `#app`,
        components: {
            "my-parent" : Parent
        }
    })
</script>
</html>